# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=earlyoom
pkgver=1.7
pkgrel=1
pkgdesc="Early OOM Daemon for Linux"
url="https://github.com/rfjakob/earlyoom"
arch="all"
license="MIT"
checkdepends="cppcheck go psutils"
subpackages="$pkgname-openrc"
source="https://github.com/rfjakob/earlyoom/archive/v$pkgver/earlyoom-$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd
	"
# FIXME: tests fail on builder, but pass locally
options="!check"

build() {
	make VERSION="v$pkgver"
}

check() {
	GO111MODULE=off make test
}

package() {
	make install DESTDIR="$pkgdir" PREFIX=/usr

	cd "$pkgdir"

	# Remove systemd stuff.
	rm -rf etc

	install -D -m755 "$srcdir"/$pkgname.initd etc/init.d/$pkgname
	install -D -m644 "$srcdir"/$pkgname.confd etc/conf.d/$pkgname
}

sha512sums="
5732632c38d9b511aaa81845b3d8f8afe737aa6498dca7e31accaf18bfcf271ba436946aa06a514a34c953f99343f9b197d8a2b8751e16d336aeb084944f3602  earlyoom-1.7.tar.gz
7dd30bf11fd0ed22209919f556675aaf4753d7cb7a832ac9809b9a618eb392a509eab9b5d70a5d6d6dd8f089d08cbcd2d77203fbd70dd7c795d616ea62fa6a7c  earlyoom.initd
518b5ed0634a8a773f6652a8906b715b9ae92601bf76f6e4803ca9e38e3428286140922e35c50f789b0e4b242c2405521eb5875d7ceb7351d017dddc0d2b30d4  earlyoom.confd
"
